package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CsvData;
import com.ruoyi.system.service.ICsvDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * k线图数据Controller
 * 
 * @author ruoyi
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/system/CsvData")
public class CsvDataController extends BaseController
{
    @Autowired
    private ICsvDataService csvDataService;




    /**
     * 查询k线图数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsvData csvData)
    {
        startPage();
        List<CsvData> list = csvDataService.selectCsvDataList(csvData);
        return getDataTable(list);
    }

    /**
     * 导出k线图数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:export')")
    @Log(title = "k线图数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsvData csvData)
    {
        List<CsvData> list = csvDataService.selectCsvDataList(csvData);
        ExcelUtil<CsvData> util = new ExcelUtil<CsvData>(CsvData.class);
        util.exportExcel(response, list, "k线图数据数据");
    }

    /**
     * 获取k线图数据详细信息
     */
    @GetMapping(value = "getKlineInfo/{id}")
    public AjaxResult getKlineInfo(@PathVariable("id") Long id)
    {
        return success(csvDataService.getKlineInfo(id));
    }

    /**
     * 获取k线图数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(csvDataService.selectCsvDataById(id));
    }

    /**
     * 新增k线图数据
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:add')")
    @Log(title = "k线图数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsvData csvData)
    {
        return toAjax(csvDataService.insertCsvData(csvData));
    }

    /**
     * 修改k线图数据
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:edit')")
    @Log(title = "k线图数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsvData csvData)
    {
        return toAjax(csvDataService.updateCsvData(csvData));
    }

    /**
     * 删除k线图数据
     */
    @PreAuthorize("@ss.hasPermi('system:CsvData:remove')")
    @Log(title = "k线图数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(csvDataService.deleteCsvDataByIds(ids));
    }
}
